package cn.com.open.itembank.logic.questiontype;

import cn.com.open.itembank.dto.QuestionImportModel;

/**
 * Created by lucky on 2017/12/19.
 */
public class SingleChoiceItem extends BaseChoiceItem {
    /**
     * Instantiates a new Single choice.
     *
     * @param model the model
     */
    public SingleChoiceItem(QuestionImportModel model) {
        super(model);
    }

    //region 校验答案格式

    /**
     * 校验答案格式.
     *
     * @return the boolean
     */
    @Override
    protected boolean checkAnswerFormat() {

        if (importModel.getAnswer().size() != 1) {
            importModel.setErrorInfo("正确答案不唯一；");
            return false;
        }

        if (answerIdList.indexOf(importModel.getAnswer().get(0).trim().toUpperCase()) < 0) {
            importModel.setErrorInfo("答案格式不正确；");
            return false;
        }

        return true;
    }
    //endregion
}
